package com.zx.sa.router;

import jakarta.annotation.Resource;
import java.util.Objects;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ModelRouter {

    @Resource(name = "openai")
    private ChatClient openai;

    @Resource(name = "gemini")
    private ChatClient gemini;

    public String chat(String input, String taskType){
        log.info("chat input={}, taskType={}",input, taskType);
        ChatClient chatClient = select(taskType);
        return chatClient.prompt().user(input).call().content();
    }

    public ChatClient select(String taskType){
        if(Objects.equals(taskType,TaskType.chat.name())){
            return openai;
        } else if (Objects.equals(taskType,TaskType.ana.name())){
            return gemini;
        }  else if (Objects.equals(taskType,TaskType.auto.name())){
            return openai;
        }
        return gemini;
    }
}
